Script windows differ in appearance and behave differently than text windows. While a text window is always a white color, a script window has one of three colors depending on the preference setting. See "Preferences" dialog.
Another distinguishing characteristic of the script window is its bottom bar. The bottom bar includes buttons for checking the script syntax and running the script. The bottom bar also includes a pull-down menu listing all handlers included in the script window. More on the bottom bar is given below.
If you are creating an applet or droplet (see applets and droplets), you need to use a script window. On the other hand, if you are creating or debugging a script, you may want to do so in a text window, at least at the start.
To open a new script window choose "New script" ( N, "File" menu). Also, see "File" menu for opening, saving and closing script windows.
Drag-and-drop and script windows
• Use drag-and-drop to rearrange text within its own script window.
• In the script window, you can drop text from / to any text window and any script window of Smile.
• You can drop from the Finder onto the script window : a text clipping, a text file (file type "TEXT"), a script (file type "osas"), an applet or a droplet (file type "APPL"). Dropping a script, applet or droplet appends its script to the end of the script window (provided it was not saved as "Run-only", see "File" menu).
• You can drop a text selection from a script window to the desktop (or to any folder) to create a text clipping.
Check syntax - Run - Toggle comments - Handlers menu
The bottom bar of the script window includes a "C" button, a run button, a check syntax button, and a list handlers pull-down menu.
Each of these is described below.
• "C" button ( "C" = Comments of Comments Pane)
Click this button (far left, bottom bar) to hide / display the comments pane. Smile and Script Editor's comments are compatible (plain text only) : when you write comments with either of the two, they are unchanged in contents and style when viewed with the other.
The Smile comments pane supports styled and colored text, Script Editor does not.
• Run Button
Click this button (gray triangle pointing to right) to execute the script. This has the same effect as selecting "Run script" ("Edit menu). Please refer to "Edit" menu for more details.
• Check Syntax Button
Click this button () to compile the script. This has the same effect as selecting "Check syntax" ("Edit" menu). The script will be compiled only if changes have been made to the active script window. Please refer to "Edit" menu for more details.
You may also press the Enter key to check syntax. Pressing the Enter key always checks syntax and compiles, independent of whether changes have been made to the active script window or not.
• List Handlers Menu
Click "Handlers" to open a menu showing the names of all handlers included in the script window. The handlers shown in the menu are listed in the same order as they appear in the script. Option-click on "Handlers" menu to have the handlers displayed alphabetically. Selecting a particular handler from the menu will cause that handler to be selected and appear in the script window.
You can insert markers in this menu. If you insert in the script window a line starting with the double-hyphen "--", followed by "mark", then the string following "mark" will be displayed in the Handlers pull-down menu. Example :
----------------------------
--mark myComments<U
----------------------------
In the example "U" (underline) has been added. Bold "B" and italic "I" could also be used. Up to two styles are supported.
Recording
Recording can be of much help while writing scripts, (provided the application you want to script is recordable). To turn recording on and off, use "Record" in the "Edit" menu. Please refer to "Edit" menu for further details.
• Smile is an attachable application. Each of Smile's objects (windows, dialogs, dialog items, buttons, ..., including Smile itself) has a script (possibly empty), called its object script.
The window of an object script is almost identical to the script window. The only differences are : object scripts do not have the "C" button, and they do not have a comments pane.
• Each of Smile's object's script has a parent class script. You may edit these files to change the behavior of the objects of a particular class. Changes to these files take effect after relaunch (unless no object of the class has been made yet). Changing the "Button", "Window", "Text Window", "Context" or "Application" Class scripts may make Smile unlaunchable.
• Editing a script usually resets its properties. This can induce much wasted time if you are debugging a big script with many properties which, for instance, need some lengthy initialization.
You can change the default behavior of a script with respect to the reset of its properties, by setting the «class SPTC» (Save Properties Through Compilation) property of the script window to true.
You may even want to change the default behavior by changing the corresponding line in the "prepare" handler of the "Script window" class script.